﻿using Simple.Services;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 违章类别分析
/// </summary>
[Route("QHSEViolationWorkYearsAnalysisController/[action]")]
[ApiController]
public class QHSEViolationWorkYearsAnalysisController : ControllerBase
{
    private readonly ViolationWorkYearsAnalysisService _violationWorkYearsAnalysisService;
    private readonly QHSEXyViolationService _violationService;


    public QHSEViolationWorkYearsAnalysisController(ViolationWorkYearsAnalysisService violationWorkYearsAnalysisService, QHSEXyViolationService violationService)
    {
        _violationWorkYearsAnalysisService = violationWorkYearsAnalysisService;
        _violationService = violationService;
    }

    /// <summary>
    /// 违章人员工龄分析--违章工龄
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> WorkYearAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationService.WorkYearAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--违章性质
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> ViolationWorkYearsTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.ViolationWorkYearsTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--通用/专业
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> ViolationWorkYearsTypeCategoryAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.ViolationWorkYearsTypeCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--各专业违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> WorkSpecialityAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.WorkSpecialityAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--各年龄段违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> AgeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.AgeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--用工性质违章性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> EmployeeTypeAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.EmployeeTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--人的不安全行为/管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> UnsafeFactorsAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.ViolationCategoryAnalysisAsync(input, "不安全因素");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--人的不安全行为
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> UnsafeBehaviorAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.ViolationCategoryAnalysisAsync(input, "人的不安全行为");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 违章人员工龄分析--管理缺陷
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_v_gl_analysis")]
    public async Task<AppResult> ManagementDeficienciesAnalysis([FromBody] ViolationAnalysisInput input)
    {
        var res = await _violationWorkYearsAnalysisService.ViolationCategoryAnalysisAsync(input, "管理缺陷");
        return AppResult.Status200OK(data: res);
    }
}
